package leetcode_1801_1900;

import java.util.Arrays;

public class LeeCode_1879 {
    public static void main(String[] args) {

    }
    private static int minimumXORSum(int[] nums1, int[] nums2) {
        int n = nums1.length, max = 1 << n;
        int[] dp = new int[max];
        Arrays.fill(dp, 1 << 30);
        dp[0] = 0;
        for (int i = 0; i < max; i++) {
            int count = Integer.bitCount(i);
            for (int j = 0; j < n; j++) {
                int pre = i ^ (1 << j);
                if (pre < i){
                    dp[i] = Math.min(dp[i], dp[pre] + (nums1[count - 1] ^ nums2[j]));
                }
            }
        }
        return dp[max - 1];
    }
}